import java.time.format.DateTimeFormatter;
import java.util.Stack;

public class AccountService {
    private Console console;
    private Calendar clock;
    private int balance;
    private Stack<String> logs = new Stack<>();
    private DateTimeFormatter formatter;

    public AccountService(Console console, Calendar clock) {
        this.console = console;
        this.clock = clock;
        formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
    }

    public void deposit(int amount) {
        balance += amount;
        logs.push(clock.currentDate().format(formatter)+ " | " + amount + " | " + balance);
    }

    public void withdraw(int amount) {
        balance -= amount;
        logs.push(clock.currentDate().format(formatter)+ " | -" + amount + " | " + balance);
    }

    public void printStatement() {
        logs.push("DATE | AMOUNT | BALANCE");
        while (!logs.isEmpty()){
            console.printLine(logs.pop());
        }
    }
}